/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.generator.repository.adaptor.method;

import com.inspur.edp.caf.generator.baseInfo.ParameterInfo;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
import com.inspur.edp.cef.designtime.api.IGspCommonField;
import com.inspur.edp.cef.designtime.api.element.GspAssociation;
import com.inspur.edp.cef.designtime.api.element.GspAssociationKey;
import com.inspur.edp.cef.entity.changeset.ValueObjModifyChangeDetail;
import com.inspur.edp.cef.entity.entity.ICefData;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGeneratorContext;
import com.inspur.edp.cef.generator.overall.GeneratorUtil;
import com.inspur.edp.cef.generator.repository.dac.DataTypeDacGenContext;
import com.inspur.edp.udt.designtime.api.entity.ComplexDataTypeDef;
import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef;
import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef;
import com.inspur.edp.udt.designtime.api.entity.dbInfo.ColumnMapType;
import java.util.ArrayList;
import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.CastExpression;
import org.eclipse.jdt.core.dom.IfStatement;
import org.eclipse.jdt.core.dom.InfixExpression;
import org.eclipse.jdt.core.dom.InstanceofExpression;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
import org.eclipse.jdt.core.dom.PrefixExpression;
import org.eclipse.jdt.core.dom.ReturnStatement;
import org.eclipse.jdt.core.dom.SwitchCase;
import org.eclipse.jdt.core.dom.SwitchStatement;

public class ChangeValueGenerator extends ClassMethodGenerator {
    private static final String NameParamName = "propertyName";
    private static final String ValueParamName = "propertyValue";
    private DataTypeDacGenContext dacContext;
    private IGspCommonDataType gspCommonDataType;
    private java.util.List<GspAssociation> associationInfos = new ArrayList<>();

    public ChangeValueGenerator(DataTypeDacGenContext dacContext, IGspCommonDataType gspCommonDataType) {
        this.dacContext = dacContext;
        this.gspCommonDataType = gspCommonDataType;
        initAssociationInfos();
    }

    @Override
    protected String getMethodName() {
        return "getPropertyChangeValue";
    }

    @Override
    protected TypeInfo getReturnType() {
        return new TypeInfo(Object.class);
    }


    @Override
    protected ArrayList<Modifier.ModifierKeyword> getAccessModifiers() {
        return new java.util.ArrayList<Modifier.ModifierKeyword>(java.util.Arrays.asList(new Modifier.ModifierKeyword[]{Modifier.ModifierKeyword.PROTECTED_KEYWORD}));
    }

    @Override
    protected boolean getIsOverride() {
        return true;
    }

    @Override
    protected ArrayList<ParameterInfo> getParameterCollection() {
        ParameterInfo tempVar = new ParameterInfo();
        tempVar.setParamType(new TypeInfo(String.class));
        tempVar.setParamName(NameParamName);
        ParameterInfo entityParam = tempVar;
        ParameterInfo tempVar2 = new ParameterInfo();
        tempVar2.setParamType(new TypeInfo(Object.class));
        tempVar2.setParamName(ValueParamName);
        ParameterInfo recordParam = tempVar2;
        return new java.util.ArrayList<ParameterInfo>(java.util.Arrays.asList(new ParameterInfo[]{entityParam, recordParam}));
    }


    ///#region MethodBody

    @Override
    protected Block buildMethodBody() {
        Block block = ast.newBlock();
        SwitchStatement switchStatement = ast.newSwitchStatement();
        switchStatement.setExpression(ast.newSimpleName(NameParamName));
        addPropertyCases(switchStatement);

        block.statements().add(switchStatement);

        return block;
    }

    private void initAssociationInfos(){
        for (IGspCommonField field : this.gspCommonDataType.getContainElements()) {
            if (field.getHasAssociation()){
                if (field.getChildAssociations() == null || field.getChildAssociations().size() < 1) {
                    continue;
                }
                for (GspAssociation association : field.getChildAssociations()) {
                    associationInfos.add(association);
                }
            }
        }
    }

    private IGspCommonField getAssoField(GspAssociation associationInfo){
        String targetElementId = "";
        for(GspAssociationKey key: associationInfo.getKeyCollection()){
            targetElementId = key.getTargetElement();
            break;
        }
        for(IGspCommonField gspCommonField: gspCommonDataType.getContainElements()){
            if(gspCommonField.getID().equals(targetElementId)){
                return gspCommonField;
            }
        }
        return null;
    }
    private void addPropertyCases(SwitchStatement switchStatement) {

        if (associationInfos != null) {
            for (GspAssociation associationInfo : associationInfos) {
                if (!isUdtAssociation(associationInfo)) {
                    addAssociationCase(associationInfo, switchStatement);
                }
            }
            for(IGspCommonField field:gspCommonDataType.getContainElements()){
                if(!field.getIsUdt())
                    continue;
                UnifiedDataTypeDef udt = (UnifiedDataTypeDef)dacContext.getReposContext().getCefContext().getCefGenContext().
                        getMetadataJitContext().getMetadata(field.getUdtID()).getContent();
                if(udt instanceof SimpleDataTypeDef || (udt instanceof ComplexDataTypeDef && ((ComplexDataTypeDef)udt).getDbInfo().getMappingType() == ColumnMapType.SingleColumn)){
                    addUdtCase( field.getLabelID(), field.getLabelID(), udt, switchStatement);
                }
                else if(udt instanceof ComplexDataTypeDef && ((ComplexDataTypeDef)udt).getDbInfo().getMappingType() == ColumnMapType.MultiColumns){
                    for(IGspCommonField child: field.getChildElements()){
                        String fieldLabel = "";
                        for(IGspCommonField udtField: udt.getContainElements()){
                            if(field.getMappingRelation().getMappingInfo(child.getID()).equals(udtField.getID())){
                                fieldLabel = udtField.getLabelID();
                                break;
                            }
                        }
                        addUdtCase( fieldLabel, child.getLabelID(), udt, switchStatement);
                    }
                }

            }
//            for (DbColumnInfo dbColumn : dbColumns) {
//                if (!dbColumn.getIsUdtElement()) {
//                    continue;
//                }
//                IGspCommonField field = null;
//                for(IGspCommonField gspCommonField: dacContext.getGspCommonDataType().getContainElements()){
//                    if(gspCommonField.getLabelID().equals(dbColumn.getColumnName()))
//                    {
//                        field = gspCommonField;
//                        break;
//                    }
//                }
//                addUdtCase( field, dbColumn, switchStatement);
////				SwitchSectionSyntax section = getUdtSection(dbColumn);
////				caseStatements.add(section);
//            }
            addDefaultCase(switchStatement);
        }
    }

    private void addAssociationCase(GspAssociation associationInfo, SwitchStatement switchStatement) {
        SwitchCase switchCase = ast.newSwitchCase();
        switchCase.setExpression(GeneratorUtil.getStringLiteral(ast, getAssoField(associationInfo).getLabelID()));
        switchStatement.statements().add(switchCase);

        addAssoIfNullStatement(switchStatement);
        addReturnAssoPropertyValueStatement(switchStatement, associationInfo);

    }

    private void addReturnAssoPropertyValueStatement(SwitchStatement switchStatement, GspAssociation associationInfo) {
        ReturnStatement returnStatement = ast.newReturnStatement();
        MethodInvocation methodInvocation = ast.newMethodInvocation();
        methodInvocation.setName(ast.newSimpleName("get" + getAssoField(associationInfo).getLabelID()));

        addReturnAssoPropValueExpression(methodInvocation, associationInfo);

        returnStatement.setExpression(methodInvocation);
        switchStatement.statements().add(returnStatement);
    }

    private void addReturnAssoPropValueExpression(MethodInvocation methodInvocation, GspAssociation associationInfo) {
        ParenthesizedExpression parenthesizedExpression = ast.newParenthesizedExpression();
        CastExpression castExpression = ast.newCastExpression();
        castExpression.setType(ast.newSimpleType(ast.newName(getEntityContext().getFieldTypeInfo(gspCommonDataType.getCode(), getAssoField(associationInfo)).getTypeName())));
        castExpression.setExpression(ast.newSimpleName(ValueParamName));

        parenthesizedExpression.setExpression(castExpression);


        methodInvocation.setExpression(parenthesizedExpression);
    }
    private EntityGeneratorContext getEntityContext(){
        return dacContext.getReposContext().getCefContext().getEntityGeneratorContext();
    }


    private void addAssoIfNullStatement(SwitchStatement switchStatement) {
        IfStatement ifStatement = ast.newIfStatement();
        InfixExpression infixExpression = ast.newInfixExpression();
        infixExpression.setLeftOperand(ast.newSimpleName(ValueParamName));
        infixExpression.setOperator(InfixExpression.Operator.EQUALS);
        infixExpression.setRightOperand(ast.newNullLiteral());
        ifStatement.setExpression(infixExpression);

        ReturnStatement returnStatement = ast.newReturnStatement();
        returnStatement.setExpression(ast.newNullLiteral());
        ifStatement.setThenStatement(returnStatement);


        switchStatement.statements().add(ifStatement);
    }

    private void addUdtCase(String udtEleLabel, String caseLabel,UnifiedDataTypeDef udt, SwitchStatement switchStatement) {
//        java.lang.Class reposType = dacContext.getReposContext().getCefContext().nestedRepositoryFactory();
//        NestedConfigAtrribute attribute = mappingAttributes.get(dbColumn.getBelongElementLabel());
//        if (attribute == null)
//            return;
//        Class configType = attribute.configType();
//        Object tempVar = ReflectionUtils.createInstance(configType);
//        INestedConfig nestedConfig = (INestedConfig) ((tempVar instanceof INestedConfig) ? tempVar : null);
//        String udtEleLabel = nestedConfig.getMapping().get(dbColumn.getColumnName());
//        UnifiedDataTypeDef udt = (UnifiedDataTypeDef)dacContext.getReposContext().getCefContext().getCefGenContext().
//                getMetadataJitContext().getMetadata(gspCommonField.getUdtID()).getContent();
        SwitchCase switchCase = ast.newSwitchCase();
        switchCase.setExpression(GeneratorUtil.getStringLiteral(ast, caseLabel));
        switchStatement.statements().add(switchCase);

        addUdtCaseValueObjModifyChange(switchStatement);
        addUdtCaseValueObjCefData(switchStatement);
        if (udt instanceof SimpleDataTypeDef || (udt instanceof ComplexDataTypeDef && ((ComplexDataTypeDef)udt).getDbInfo().getMappingType() == ColumnMapType.SingleColumn)){
            udtEleLabel = udt.getCode();
        }
        addUdtReturnStatement(switchStatement,udtEleLabel, udt);
    }

    private void addUdtCaseValueObjModifyChange(SwitchStatement switchStatement) {
        IfStatement ifStatement = ast.newIfStatement();
        InstanceofExpression instanceofExpression = ast.newInstanceofExpression();
        instanceofExpression.setLeftOperand(ast.newSimpleName(ValueParamName));
        instanceofExpression.setRightOperand(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(ValueObjModifyChangeDetail.class).getType(ast));
        ifStatement.setExpression(instanceofExpression);

        Block block = ast.newBlock();
        Assignment assignment = ast.newAssignment();
        assignment.setLeftHandSide(ast.newSimpleName(ValueParamName));
        assignment.setOperator(Assignment.Operator.ASSIGN);

        MethodInvocation methodInvocation = ast.newMethodInvocation();
        methodInvocation.setName(ast.newSimpleName("getData"));
        ParenthesizedExpression parenthesizedExpression=ast.newParenthesizedExpression();
        CastExpression castExpression=ast.newCastExpression();
        castExpression.setExpression(ast.newSimpleName(ValueParamName));
        addImport(ValueObjModifyChangeDetail.class.getTypeName());
        castExpression.setType(new TypeInfo(ValueObjModifyChangeDetail.class).getType(ast));
        parenthesizedExpression.setExpression(castExpression);

        methodInvocation.setExpression(parenthesizedExpression);
        assignment.setRightHandSide(methodInvocation);

        block.statements().add(ast.newExpressionStatement(assignment));

        ifStatement.setThenStatement(block);


        switchStatement.statements().add(ifStatement);
    }

    private void addUdtCaseValueObjCefData(SwitchStatement switchStatement) {
        IfStatement ifStatement = ast.newIfStatement();
        addUdtCaseValueObjCefDataIfExpression(ifStatement);
        addUdtCaseValueObjCefDataIfThen(ifStatement);

        switchStatement.statements().add(ifStatement);
    }

    private void addUdtCaseValueObjCefDataIfExpression(IfStatement ifStatement) {
        PrefixExpression prefixExpression = ast.newPrefixExpression();
        prefixExpression.setOperator(PrefixExpression.Operator.NOT);

        ParenthesizedExpression parenthesizedExpression = ast.newParenthesizedExpression();
        InstanceofExpression instanceofExpression = ast.newInstanceofExpression();
        instanceofExpression.setLeftOperand(ast.newSimpleName(ValueParamName));
        instanceofExpression.setRightOperand(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(ICefData.class).getType(ast));

        parenthesizedExpression.setExpression(instanceofExpression);


        prefixExpression.setOperand(parenthesizedExpression);
        ifStatement.setExpression(prefixExpression);
    }

    private void addUdtCaseValueObjCefDataIfThen(IfStatement ifStatement) {
        Block block = ast.newBlock();
        ReturnStatement returnStatement = ast.newReturnStatement();
        returnStatement.setExpression(ast.newSimpleName(ValueParamName));
        block.statements().add(returnStatement);
        ifStatement.setThenStatement(block);
    }

    private void addUdtReturnStatement(SwitchStatement switchStatement, String udtEleLabel, UnifiedDataTypeDef udt) {
        ReturnStatement returnStatement = ast.newReturnStatement();
        MethodInvocation methodInvocationgetPersistenceValue = ast.newMethodInvocation();
        addgetPersistenceValueMethodExpression(methodInvocationgetPersistenceValue, udt);
        methodInvocationgetPersistenceValue.setName(ast.newSimpleName("getPersistenceValue"));
        methodInvocationgetPersistenceValue.arguments().add(GeneratorUtil.getStringLiteral(ast, udtEleLabel));

        CastExpression castExpression=ast.newCastExpression();
        castExpression.setExpression(ast.newSimpleName(ValueParamName));
        castExpression.setType(new TypeInfo(ICefData.class).getType(ast));
        methodInvocationgetPersistenceValue.arguments().add(castExpression);

        returnStatement.setExpression(methodInvocationgetPersistenceValue);
        switchStatement.statements().add(returnStatement);
    }

    private void addgetPersistenceValueMethodExpression(MethodInvocation methodInvocationgetPersistenceValue, UnifiedDataTypeDef udt) {
        MethodInvocation methodInvocationCreateRepository = ast.newMethodInvocation();
//        addcreateRepositoryExpression(methodInvocationCreateRepository);
        methodInvocationCreateRepository.setName(ast.newSimpleName("getNestedRepository"));
        methodInvocationCreateRepository.arguments().add(GeneratorUtil.getStringLiteral(ast, udt.getUdtType()));


        methodInvocationgetPersistenceValue.setExpression(methodInvocationCreateRepository);
    }

    private void addcreateRepositoryExpression(MethodInvocation methodInvocationCreateRepository) {
        MethodInvocation methodInvocation2=ast.newMethodInvocation();
        methodInvocation2.setName(ast.newSimpleName("getUdtRepositoryFactory"));
        methodInvocation2.setExpression(ast.newName("com.inspur.edp.udt.api.UdtManagerUtils"));
        methodInvocationCreateRepository.setExpression(methodInvocation2);
    }

//	private void test()
//	{
//		case "BillTypeID":
//		if (propertyValue instanceof ValueObjModifyChangeDetail)
//		{
//			propertyValue = propertyValue.getData();
//		}
//		if (!(propertyValue instanceof ICefData))
//		{
//			return propertyValue;
//		}
//		return new UdtRepositoryFactory().createRepository("Inspur.GS.BF.BC.BusinessTypes.udt.BusinessTypes.BusinessTypes").getPersistenceValue("BusinessTypes", propertyValue);
//	}

    private void addDefaultCase(SwitchStatement switchStatement) {
        SwitchCase switchCase = ast.newSwitchCase();
        switchCase.setExpression(null);
        switchStatement.statements().add(switchCase);
        ReturnStatement returnStatement = ast.newReturnStatement();
        returnStatement.setExpression(ast.newSimpleName(ValueParamName));
        switchStatement.statements().add(returnStatement);
    }

    private boolean isUdtAssociation(GspAssociation associationInfo) {
        if(getAssoField(associationInfo) != null){
            return getAssoField(associationInfo).getIsUdt();
        }
        return false;
    }
//	private SwitchStatementSyntax getSwitchStatement()
//	{
//		java.util.ArrayList<SwitchSectionSyntax> caseStatements = new java.util.ArrayList<SwitchSectionSyntax>();
//
//		if (associationInfos != null)
//		{

//			for (var associationInfo : associationInfos)
//			{
//				if (!IsUdtAssociation(associationInfo))
//				{
//					caseStatements.add(getCaseStatement(associationInfo));
//				}
//			}
//		}

//		for (var dbColumn : dbColumns)
//		{
//			if (!dbColumn.IsUdtElement)
//			{
//				continue;
//			}
//			SwitchSectionSyntax section = getUdtSection(dbColumn);
//			caseStatements.add(section);
//		}
//		caseStatements.add(getDefaultStatement());
//		return SyntaxFactory.SwitchStatement(SyntaxFactory.IdentifierName(NameParamName)).WithSections(SyntaxFactory.List(caseStatements.toArray(new SwitchSectionSyntax[]{})));
//	}

//
//         case "SalesCompany":
//            if (propertyValue is ValueObjModifyChangeDetail)
//            {
//                propertyValue = ((ValueObjModifyChangeDetail)propertyValue).Data;
//            }
//
//            if(!(propertyValue is ICefData))
//                return propertyValue;
//
//            return new global::Inspur.Gsp.Udt.RtGenerator.UdtRepositoryFactory().CreateRepository("Inspur.GS.scm.sd.salesorder1.udt.Company.Company").getPersistenceValue("Company", (ICefData)propertyValue);
//
    //TODO: 运行时新增和修改都会走这个方法, 但是新增前会走GetPersistenceValue, 培训先兼容一下
//	private SwitchSectionSyntax getUdtSection(DbColumnInfo columnInfo)
//	{
//		java.lang.Class reposType = dacContext.getReposContext().getCefContext().nestedRepositoryFactory();

//		var attribute = mappingAttributes.get(columnInfo.getBelongElementLabel());

//		var configType = attribute.ConfigType;
//		Object tempVar = configType.Assembly.CreateInstance(configType.FullName);

//		var nestedConfig = (INestedConfig)((tempVar instanceof INestedConfig) ? tempVar : null);

//		var udtEleLabel = nestedConfig.Mapping[columnInfo.getColumnName()];
//
//		return SyntaxFactory.SwitchSection().WithLabels(SyntaxFactory.<SwitchLabelSyntax>SingletonList(SyntaxFactory.CaseSwitchLabel(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(columnInfo.getColumnName()))))).WithStatements(SyntaxFactory.<StatementSyntax>List(new StatementSyntax[]{ SyntaxFactory.IfStatement(SyntaxFactory.BinaryExpression(SyntaxKind.IsExpression, SyntaxFactory.IdentifierName(ValueParamName), TypeUtils.getTypeSyntax(ValueObjModifyChangeDetail.class)), SyntaxFactory.Block(SyntaxFactory.<StatementSyntax>SingletonList(SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, SyntaxFactory.IdentifierName(ValueParamName), SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.ParenthesizedExpression(SyntaxFactory.CastExpression(TypeUtils.getTypeSyntax(ValueObjModifyChangeDetail.class), SyntaxFactory.IdentifierName(ValueParamName))), SyntaxFactory.IdentifierName("Data"))))))), SyntaxFactory.IfStatement(SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, SyntaxFactory.ParenthesizedExpression(SyntaxFactory.BinaryExpression(SyntaxKind.IsExpression, SyntaxFactory.IdentifierName(ValueParamName), TypeUtils.getTypeSyntax(ICefData.class)))), SyntaxFactory.ReturnStatement(SyntaxFactory.IdentifierName(ValueParamName))), SyntaxFactory.ReturnStatement(SyntaxFactory.InvocationExpression(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.InvocationExpression(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.ObjectCreationExpression(TypeUtils.getTypeSyntax(reposType)).WithArgumentList(SyntaxFactory.ArgumentList()), SyntaxFactory.IdentifierName("CreateRepository"))).WithArgumentList(SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(nestedConfig.ConfigId)))))), SyntaxFactory.IdentifierName("getPersistenceValue"))).WithArgumentList(SyntaxFactory.ArgumentList(SyntaxFactory.<ArgumentSyntax>SeparatedList(new SyntaxNodeOrToken[] { SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(udtEleLabel))), SyntaxFactory.Token(SyntaxKind.CommaToken), SyntaxFactory.Argument(SyntaxFactory.CastExpression(TypeUtils.getTypeSyntax(ICefData.class), SyntaxFactory.IdentifierName(ValueParamName))) }))))}));
//	}
//
//	private SwitchSectionSyntax getCaseStatement(AssociationInfo associationInfo)
//	{
//		return SyntaxFactory.SwitchSection().WithLabels(SyntaxFactory.<SwitchLabelSyntax>SingletonList(SyntaxFactory.CaseSwitchLabel(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(associationInfo.getSourceColumn()))))).WithStatements(SyntaxFactory.<StatementSyntax>SingletonList(SyntaxFactory.Block(SyntaxFactory.IfStatement(SyntaxFactory.BinaryExpression(SyntaxKind.EqualsExpression, SyntaxFactory.IdentifierName(ValueParamName), SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)), SyntaxFactory.ReturnStatement(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))),
//				SyntaxFactory.ReturnStatement(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.ParenthesizedExpression(SyntaxFactory.BinaryExpression(SyntaxKind.AsExpression, SyntaxFactory.IdentifierName(ValueParamName), TypeUtils.getTypeSyntax(associationInfo.getAssociationType()))), SyntaxFactory.IdentifierName(associationInfo.getSourceColumn()))))));
//	}
//
//	private SwitchSectionSyntax getDefaultStatement()
//	{
//		return SyntaxFactory.SwitchSection().WithLabels(SyntaxFactory.<SwitchLabelSyntax>SingletonList(SyntaxFactory.DefaultSwitchLabel())).WithStatements(SyntaxFactory.<StatementSyntax>SingletonList(SyntaxFactory.ReturnStatement(SyntaxFactory.IdentifierName(ValueParamName))));
//	}


    ///#endregion
}
